// 导入 Mock.js 库
import Mock from 'mockjs';

// 定义随机商机标题的生成规则
Mock.Random.extend({
    chineseTitle: function() {
        const words = Mock.Random.cword(3, 6); // 随机生成 3 到 6 个汉字
        return words;
    }
});

// 定义商机数据模板类型
interface OpportunityTemplate {
    title: string;
    customer: string;
    stage: string;
    quoteRecord: string;
    totalAmount: string;
    totalData:string;
}

// 使用 Mock.js 定义商机数据模板
const template: OpportunityTemplate = {
    title: '@chineseTitle', // 随机中文商机标题
    customer: '@cname', // 随机中文客户名称
    stage: '@pick(["跟进记录", "未跟进记录"])', // 随机选择商机阶段
    quoteRecord: '@integer(1, 10)', // 随机报价记录，范围为 1 到 10
    totalAmount: '@integer(1000, 100000)', // 随机报价总金额，范围为 1000 到 100000
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
};

// 使用 Mock.js 生成随机商机数据
const opportunities: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;
const systemHomePage: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;
const customerList: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;
const customerFiltering: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;
const salesLeads: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;
const allOrders: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;
const subordinateOrders: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;
const myCollaborations: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;
const subordinateCollaborations: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;
const addOrder: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;
const myOrders: OpportunityTemplate[] = Mock.mock({
  'list|100': [{
    title: '@chineseTitle',
    customer: '@cname',
    'stage|1': ['跟进记录', '未跟进记录'],
    'quoteRecord|1-10': 1,
    'totalAmount|1000-100000': 1000,
    totalData: '@date(yyyy-MM-dd hh:mm:ss)',
  }]
}).list;

export default [
  {
    url: "/list",
    methods: "get",
    response: () => {
      return opportunities;
    },
  },
  {
    url: "/list",
    methods: "get",
    response: () => {
      return opportunities;
    },
  },
  {
    url: "/list/systemHomePage",
    methods: "get",
    response: () => {
      return systemHomePage;
    },
  },
  {
    url: "/list/customerList",
    methods: "get",
    response: () => {
      return customerList;
    },
  },
  {
    url: "/list/customerFiltering",
    methods: "get",
    response: () => {
      return customerFiltering;
    },
  },
  {
    url: "/list/salesLeads",
    methods: "get",
    response: () => {
      return salesLeads;
    },
  },
  {
    url: "/list/allOrders",
    methods: "get",
    response: () => {
      return opportunities;
    },
  },
  {
    url: "/list/subordinateOrders",
    methods: "get",
    response: () => {
      return opportunities;
    },
  },
  {
    url: "/list/myCollaborations",
    methods: "get",
    response: () => {
      return opportunities;
    },
  },
  {
    url: "/list/addOrder",
    methods: "get",
    response: () => {
      return opportunities;
    },
  },
  {
    url: "/list/myCollaborations",
    methods: "get",
    response: () => {
      return opportunities;
    },
  },
  {
    url: "/list/myCollaborations",
    methods: "get",
    response: () => {
      return opportunities;
    },
  },
  {
    url: "/list/myCollaborations",
    methods: "get",
    response: () => {
      return opportunities;
    },
  },
];
